<template>
 <div class="way">
    <el-card class="left">
      <div class="search">
        <el-input
          placeholder="请输入"
          prefix-icon="el-icon-search"
          size="mini"
          >
        </el-input>
      </div>
      <el-menu v-if="locationId != ''"
        :router="false"
        :unique-opened="false"
        text-color="#333"
        @select="selectMenu"
        :default-active="menuList[0].locationId"
      >
        <el-menu-item v-for="m in menuList" :key="m.locationId" :index="m.locationId" >
          <span slot="title">{{m.locationName}}</span>
        </el-menu-item>
      </el-menu>
    </el-card>
    <div class="right">
     <way-list :locationId="locationId"></way-list>
    </div>
  </div>
</template>

<script>

import WayList from './components/WayList.vue'
import siteApi from '@/network/map/site.api'
export default {
  name: 'Way',
  components: {
    WayList
  },
  data() {
    return {
      menuList: [],
      locationId: '',
    }
  },
  created() {
    this.getMenuList()
  },
  methods: {
    selectMenu(index) {
      this.locationId = index
    },
    async getMenuList() {
      const {locationList} = await siteApi.getSiteList(1,100)
      this.locationId = locationList[0].locationId
      this.menuList = locationList
    }
  }
}
</script>


<style lang="scss" scoped>
.way {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: space-between;
}
.left {
  width: 280px;
  height: calc(100vh - 100px);
}
.el-menu {
 margin-top: 20px; 
}
.el-menu-item {
  height: 28px;
  line-height: 28px;
}
.right {
  // flex: 1;
  width: calc(100% - 300px);
  margin-left: 20px;
}
</style>